package com.xy.biz.ts.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.ts.domain.req.UpdatePracticeRecordRequest;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.ts.domain.bo.PracticeRecordBO;
import com.xy.biz.ts.domain.po.PracticeRecordPO;
import com.xy.biz.ts.domain.query.PracticeRecordQuery;
import com.xy.biz.ts.domain.resp.GetPracticeRecordResponse;
import com.xy.biz.ts.domain.req.SavePracticeRecordRequest;
import com.xy.biz.ts.domain.req.ListPracticeRecordRequest;

/**
 *
 *
 * @author wwj
 * @date 2021-4-7
 */
public class PracticeRecordConverter {

	public static PracticeRecordPO toPO(PracticeRecordBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new PracticeRecordPO(), true);
	}

	public static List<PracticeRecordPO> toPO(Collection<PracticeRecordBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new PracticeRecordPO(), true);
	}

	public static PracticeRecordBO fromPO(PracticeRecordPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new PracticeRecordBO());
	}

	public static List<PracticeRecordBO> fromPO(Collection<PracticeRecordPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new PracticeRecordBO());
	}

	public static PracticeRecordBO toBO(SavePracticeRecordRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new PracticeRecordBO(), true);
	}

	public static PracticeRecordBO toBO(UpdatePracticeRecordRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new PracticeRecordBO(), true);
	}

	public static List<PracticeRecordBO> toBO(Collection<SavePracticeRecordRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new PracticeRecordBO(), true);
	}

	public static GetPracticeRecordResponse toResponse(PracticeRecordBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetPracticeRecordResponse());
	}

	public static List<GetPracticeRecordResponse> toResponse(Collection<PracticeRecordBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetPracticeRecordResponse());
	}

	public static PracticeRecordQuery toQuery(ListPracticeRecordRequest source) {
		if(null == source) {
			return null;
		}
		PracticeRecordQuery target = new PracticeRecordQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
